;Yokogawa WT3000 series Power Analyzers
;  Tested over Ethernet with Test Controller V1.70.  Earlier versions will not work.
;6/28/2021 Rev D   Setup 32 Channels and initialize device to remove echo from replies
;6/26/2021 Rev C   Fully automated login for anonymous user with no password.  Logging working.
;5/28/2021 Rev B   Use Yokogawa limited info on "legacy protocol" to make progress.
;4/30/2021 Rev A

;Per Yokogawa manual "Port number: 10001/tcp" and it uses a socket connection.
;Other newer Yokogawa power analyzsers are LXI compliant but not the WT3000 series.

#verifyDevice Ctl_server_is_ready. loginy?
; Below ID string response to query? *idn? from up to date unit on 7/2/21.
#idString YOKOGAWA,760304-04-MV,0,F6.31AD
#name Yokogawa WT3000
#handle WT3000
#port 10001
#driver asciiBin
#packetFormat Length31
#eol \_
#author gby
#notes Yokogawa WT3000 series instruments are multi-channel power analyzers.  This driver uses the Ethernet communications option with socket connection.  Automatically logs into the Yokogawa with user name anonymous and blank password.  If the device has other account settings this will not work.  A modified form of this device file might work with RS232 or GPIB communications.

; A list of possible column name with unit and formatter (SI, Time, Int, D0..D6) 
; Format: #value ColumnName Unit Format {Selector}
; Selector is only used when column layout varies with mode, this often require the use of #cmdMode
; Yokogawa allows any quantity (V, I, Watt, speed, ...) on any channel.  So below lists no units.

#value CH1 - D3
#value CH2 - D3
#value Ch3 - D3
#value Ch4 - D3
#value Ch5 - D3
#value Ch6 - D3
#value Ch7 - D3
#value Ch8 - D3
#value Ch9 - D3
#value Ch10 - D3
#value Ch11 - D3
#value Ch12 - D3
#value Ch13 - D3
#value Ch14 - D3
#value Ch15 - D3
#value Ch16 - D3
#value CH17 - D3
#value CH18 - D3
#value Ch19 - D3
#value Ch20 - D3
#value Ch21 - D3
#value Ch22 - D3
#value Ch23 - D3
#value Ch24 - D3
#value Ch25 - D3
#value Ch26 - D3
#value Ch27 - D3
#value Ch28 - D3
#value Ch29 - D3
#value Ch30 - D3
#value Ch31 - D3
#value Ch32 - D3

; How to poll for data, this is used for table and #values?
; a #askMode, #cmdMode and #prepareSample is used before this is string is used.--
; Number of returned values must match number of columns defined with #value
; This is a single line command

;  Yokogawa :num:norm:val? gets data values 1 through the set value of :NUMeric:NORMal:NUMber
#askValues query? :num:norm:val?

; Format of answer: f=float, u=remove trailing letters, x=skip, *=Zero upper case values if this value is 0
#askValuesReadFormat ffffffffffffffffffffffffffffffff

; There must be a line for each of the original device commands that will be used, converting it to a similar SCPI command
;#scpiCmd init tx command to init
;#scpiCmd values? txrx? command to read current value or values. It is possible to define value1?, value2?, etc. and then use them all with a ; between in the #askValues statement.

; Accept this delay when reading values (seconds)
#readingDelay 2

; Mode change have a longer delay on reading values (seconds)
#modeChangeDelay 10

; String to ask about actual meter mode, it is mostly used for DMM's
; This is a single line command
;#askMode 

; When one of these commands are used through the command interface a new configuration will be done before using #askMode
; Only one word for each #mayModifyMode
; Specify command without initial colon and in the shortest possible form
;#mayModifyMode 

; Prepare the meter to response to #askValues
;#prepareSample arm:sour imm;:arm:count 1;:trig:sour imm;:trig:count 1;:trig:samp:count 1;init

; Initial commands to meter when establishing connection, used to disable local control
; Set recorder to full sample rate, immediate trigger, take only 1 point, send as decimal numbers.
; Leave REC.CHx channels selections at whatever is in the drive.

;  Below sets the Yokogawa to:
;      - send numeric values as ascii IEEE single precision float numbers.
;      - turns command echo off for query replies.  Just returns value.
;      - to only return the first 32 of a possible 255 values from :NUM:NORM:VAL?
;
;  Changing the number of channels logged requires changing:
;      number of #value lines
;      number of format characters in #askValuesReadFormat.
#initCmd sety :NUMERIC:FORMAT ASCII; sety communicate:header 0; sety :NUMERIC:NORMAL:NUMBER 32

; Final command to meter before breaking connection, used to restore local control
; Put REC data format back to default.
;#finalCmd

; Used to turn output off for power supplies, generators and electronic loads
;Also AXIS2.DIS?; for dual axis.  Delay at end add ;[xxx] for xxx mSec delay after.
;#outputOff


;*****************  Define SCPI Commands    *****************
;  Use below query command with Yokogawa communications command to get a value/setting.
#scpiCmd query? txrx (value)
txrx
txrx
txrx?

;  Use below set command with Yokogawa communications command to set a value/setting
#scpiCmd sety txrx (value)

;  Below command used in the #verifyDevice command at device connect to log into the device.
#scpiCmd loginy? txrx anonymous
txrx
txrx
txrx
txrx?

